package com.ranyk.www.base;

import com.ranyk.www.enums.ResponseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * CLASS_NAME: BaseResult.java <br/>
 *
 * @author ranyk           <br/>
 * @version V1.0           <br/>
 * @decription: 基础结果对象 <br/>
 * @date: 2022-04-01 <br/>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("unused")
@ApiModel(description = "基础结果返回对象")
public class BaseResult implements Serializable {

    @Serial
    private static final long serialVersionUID = -1211356086883899248L;

    /**
     * 返回状态码
     */
    @ApiModelProperty(value = "返回状态码,默认 200")
    private Integer code;
    /**
     * 返回信息
     */
    @ApiModelProperty(value = "返回信息,默认 success")
    private String message;
    /**
     * 返回数据
     */
    @ApiModelProperty(value = "返回数据,默认为空")
    private Object data;


    /**
     * 构造函数
     *
     * @param code    返回状态码
     * @param message 返回信息
     */
    public BaseResult(Integer code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    /**
     * 构造函数
     *
     * @param data 返回的数据
     */
    public BaseResult(Object data) {
        super();
        this.code = ResponseEnum.SUCCESS.getCode();
        this.message = ResponseEnum.SUCCESS.getMsg();
        this.data = data;
    }

}
